import jdbc.JdbcUtils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

public class druid_properties {
    public static void main(String[] args) throws IOException, SQLException {
        /*Properties ps=new Properties();
        ps.put("deiverClassName","com.mysql.jdbc.Driver");
        ps.put("url","jdbc:mysql://127.0.0.1:3306/学生库?useSSL=false&useServerPrepStmts=true");
        ps.put("username","root");
        ps.put("password","mysql");
        ps.put("initialSize","5");
        ps.put("maxActive","10");
        ps.put("maxWait","3000");
        FileOutputStream outputStream=new FileOutputStream("D:\\idea2022\\day.com.qiezi\\day_12\\src\\druid.properties");
        ps.store(outputStream,"p");
        outputStream.close();*/
        //使用工具类
        Connection connection = JdbcUtils.getConnection();
        String sql="select * from student;";
        //获取sql执行对象
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            String id = resultSet.getString(1);
            String sname = resultSet.getString(2);
            String ssex = resultSet.getString(3);
            System.out.println(id+sname+ssex);
        }
        //回收连接
        jdbc.JdbcUtils.returnConnection(connection);
    }
}
